package webUtils.buzhidao;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.google.common.collect.Lists;

import webUtils.GetSign;

/**
* @author 作者 linweiqiang
* @version 创建时间：2017年9月29日 下午5:03:52
* 类说明
*/
public  class HttpMain {
	
	/**
     * 模拟并发测试
     */
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        //模拟并发数
        int concurrencyNumber = 1000;
        
        List<String>  resList = Lists.newArrayList();
        
        //执行线程池
        ExecutorService ex = Executors.newFixedThreadPool(100);
        
        String url = "http://www.baidu.com";
        Map<String, String> mapPatam = new HashMap<>();
        mapPatam.put("name", "测试");
        List<NameValuePair> list = new ArrayList<NameValuePair>();
        list.add(new BasicNameValuePair("66", "66"));
        for(int i =0 ; i< 4; i++){
            Future<String> callRes = ex.submit(new HttpCallable(url, list));
            resList.add(i + ">>>" + callRes.get());
            System.out.println("------>" );
        }
        
        for(String s : resList){
            System.out.println("------>" + s);
        }
    }
}
